package com.zhangck.bos2_0.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.zhangck.bos2_0.Service.TakeTimeService;
import com.zhangck.bos2_0.common.BaseAction;

import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.domain.base.TakeTime;

/** 
* @author 上午茶
* @version 创建时间：2018年6月3日 下午3:18:31 
* 类说明 
*/
@ParentPackage("json-default")
@Namespace("/")
@Scope("prototype")
@Actions
@Controller
public class TakeTimeAction  extends BaseAction<Area> {

	@Autowired
	private TakeTimeService TakeTimeService;

	//分页
	@Action(value="take_timepage",results={@Result(name="success",type="json")})
	public String  take_timepage(){
		Pageable request = new PageRequest(page-1, rows);
		Page<TakeTime> page1 = TakeTimeService.finddatapage(request);

		Map<String, Object> map = new HashMap();
		map.put("total", page1.getTotalElements());//必须得用total接受
		map.put("rows", page1.getContent());
		
		
		ActionContext.getContext().getValueStack().push(map);
		
		return  "success";
	}

	@Action(value="TakeTimeAction_find",results={@Result(name="success",type="json")})
	public String  TakeTimeAction_find(){
	  List<TakeTime> list= TakeTimeService.findAll();
		ServletActionContext.getContext().getValueStack().push(list);
		return "success";
	}
}
